package day20180129.designMode.six_Prototype;

/**
 * Created by 14394 on 2018/1/29.
 */

//实现Product接口，实现复制
public class MessageBox implements Product {
    private char decochar;

    public MessageBox(char decochar) {
        this.decochar = decochar;
    }

    @Override
    public void use(String s) {
        int length = s.getBytes().length;
        System.out.println("\"" + s+ "\"");
        for (int i=0;i<length+4;i++){
            System.out.print(decochar);
        }
        System.out.println("");

    }

    @Override
    public Product createClone() {
        Product p = null;
        try {
             p = (Product) clone();//调用了product接口的父类Colneable接口的方法
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return  p;
    }
}
